#!/bin/bash

get_os_info() {
    os_description=`lsb_release -d | cut -d : -f 2 | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//'`
    os_arch=`uname -m`
    echo "[INFO]os_description:$os_description"
    echo "[INFO]os_arch:$os_arch"
    echo "[INFO]chroot_version:$chroot_version"
}

kernel_path_stub() {
    if [ "${os_description}"x == "Ubuntu 20.04.5 LTS"x ]; then
        ker_path="/lib/modules/5.4.0-125-generic/build"
    fi
    if [ "${os_description}"x == "Ubuntu 20.04 LTS"x ]; then
        ker_path="/lib/modules/5.4.0-26-generic/build"
    fi
    if [ "${os_description}"x == "Ubuntu 22.04 LTS"x ]; then
        ker_path="/lib/modules/5.15.0-25-generic/build"
    fi
    if [ "${os_description}"x == "Huawei Cloud EulerOS release 2.0 (West Lake)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/5.10.0-60.18.0.50.r865_35.hce2.aarch64/build"
    fi
    if [ "${os_description}"x == "Huawei Cloud EulerOS release 2.0 (West Lake)"x -a "${os_arch}"x == "x86_64"x ]; then
        ker_path="/lib/modules/5.10.0-60.18.0.50.r865_35.hce2.x86_64/build"
    fi
    if [ "${os_description}"x == "CentOS Linux release 7.6.1810 (Core)"x -a "${os_arch}"x == "x86_64"x ]; then
        ker_path="/lib/modules/3.10.0-957.el7.x86_64/build"
    fi
    if [ "${os_description}"x == "CentOS Linux release 7.6.1810 (AltArch)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/4.14.0-115.el7a.0.1.aarch64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP11)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/5.10.0-60.18.0.50.h665.eulerosv2r11.aarch64/build"
    fi
    if [ "${os_description}"x == "Debian GNU/Linux 9.9 (stretch)"x -a "${os_arch}"x == "x86_64"x ]; then
        ker_path="/lib/modules/4.19.28/build"
    fi
    if [ "${os_description}"x == "Debian GNU/Linux 10.0 (buster)"x -a "${os_arch}"x == "x86_64"x ]; then
        ker_path="/lib/modules/4.19.0-5-amd64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP8)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/4.19.36-vhulk1907.1.0.h619.eulerosv2r8.aarch64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP9)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/4.19.90-vhulk2009.2.0.h269.eulerosv2r9.aarch64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP10)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/4.19.90-vhulk2107.1.0.h699.eulerosv2r10.aarch64/build"
    fi
    if [ "${os_description}"x == "Huawei Cloud EulerOS release 2.0 (West Lake)"x -a "${os_arch}"x == "x86_64"x ]; then
        ker_path="/lib/modules/5.10.0-60.18.0.50.r865_35.hce2.x86_64/build"
    fi
    if [ "${os_description}"x == "Huawei Cloud EulerOS release 2.0 (West Lake)"x -a "${os_arch}"x == "aarch64"x ]; then
        ker_path="/lib/modules/5.10.0-60.18.0.50.r865_35.hce2.aarch64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP9x86_64)"x -a "${chroot_version}"x == "V200R009C10SPC102B590"x ]; then
        ker_path="/lib/modules/4.18.0-147.5.1.2.h340.eulerosv2r9.x86_64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP9x86_64)"x -a "${chroot_version}"x == "V200R009C00SPC200B290"x ]; then
        ker_path="/lib/modules/4.18.0-147.5.1.0.h208.eulerosv2r9.x86_64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP10x86_64)"x ]; then
        ker_path="/lib/modules/4.18.0-147.5.2.1.h579.eulerosv2r10.x86_64/build"
    fi
    if [ "${os_description}"x == "EulerOS release 2.0 (SP5)"x -a "${os_arch}"x == "x86_64"x ]; then
        ker_path="/lib/modules/3.10.0-862.14.1.5.h428.eulerosv2r7.x86_64/build"
    fi
}

# start
get_os_info
kernel_path_stub